package com.acme.task1;

public class Calculator {
	private final static String LENGTH = "not enought params: ";
	private final static String UNKNOWN_OP = "UNKNOWN OPERATOR: ";
	private final static String DIVINE_BY_ZERO = "DIVINE BY ZERO";

	public static void main(String[] args) throws IllegalArgumentException{
		final double result;
		// TODO: analyze number of arguments
		if (args.length < 3) {
			throw new IllegalArgumentException(LENGTH + args.length);
		}

		// TODO: get arguments
		double operand1 = Double.valueOf(args[0]);
		double operand2 = Double.valueOf(args[2]);

		char op = args[1].charAt(0);
		// TODO: analyze operation and make calculations
		switch (op) {
		case '+':
			result = operand1 + operand2;
			break;
		case '-':
			result = operand1 - operand2;
			break;
		case '*':
			result = operand1 * operand2;
			break;
		case '/':
			if (operand2 == 0.)
				throw new IllegalArgumentException(DIVINE_BY_ZERO);
			result = operand1 / operand2;
			break;
		default:
			throw new IllegalArgumentException(UNKNOWN_OP + op);
		}
		// printing result
		System.out.println(result);
	}
}
